package br.com.ffm.praticas.filemanager;

import java.beans.XMLEncoder;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

public class FileManager {
	
	private File file;
	
	public FileManager(String path) {
		file = new File(path);
	}
	
	/**
	 * Method that save a List<Object>
	 * @param list List<Object> to save
	 * @return true if save or false if don't save
	 */
	public boolean saveData(List<?> list) {
		try {
			XMLEncoder encoder = new XMLEncoder( new FileOutputStream(this.file));
			encoder.get(list);
			encoder.close();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
